<?

function register($array){


	$uploadfile = "../picture/".$array["id"];

	if (move_uploaded_file($_FILES['attach']['tmp_name'], $uploadfile)) {
		$hasPicture = "1";
	} else {
		$hasPicture = "0";
	}

	$query1= "insert into users set id='".$array["id"].
					"', password ='"	.$array["password"].
					"', age='"				.$array["age"].
					"', gender='"			.$array["gender"].
					"', self='"				.$array["self"].
					"', hasPicture='"                             .$hasPicture.
					"', name='"				.$array["name"]."'";
	$result1 = mysql_query($query1);

	$query2= "insert into keywords set id='".$array["id"].
					"', keyword = '"	.$array["keyword"]."'";
	
	$result2 = mysql_query($query2);
	if(!$result1 || !$result2)
			return null;
	
	return $result1;
} // end of function 'register'


// example : use of function 'register'
// make an array which information of the user are in and call the function with it.
// make sure that index of the array are corresponding DB columns
//
// assume that the array variable is $user, and then
//
// $user["id"] -> id(email) to be registered and must have value
// $user["password"] -> password
// $user["age"] -> user's age 
// $user["gender"] -> user's gender 
// $user["keyword"] -> keywords about the user
// 





// db connection

function connectDB(){
	$db = mysql_pconnect("localhost", "palhunt", "palhunt");
	if (!$db){
		echo "Error : Could not connect to database."; 
		exit;
	}
	mysql_select_db("PalHunt");
}
// end of db connection


?>
